﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FanaticRock.DownloadManage.Helpers
{
    public static class DownloadBytesHelper
    {
        // http://i0.hdslb.com/bfs/archive/b48ef2dca53d7d83f9f46d4b0c1ba8b57576285e.jpg@140w_80h_1c.webp
        public static async Task<byte[]> GetBytes(string uri)
        {
            return await DownloadHelper._httpClient.GetByteArrayAsync(uri);
        }

        public static async Task<byte[]> GetBytes(Uri uri)
        {
            var filePath = uri.LocalPath;
            if(File.Exists(filePath)) return File.ReadAllBytes(filePath);
            return await DownloadHelper._httpClient.GetByteArrayAsync(uri);
        }
    }
}
